<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input type="button" value="打开窗口" onclick="dakai()" />
		<input type="button" value="关闭窗口" onclick="guanbi()" />
		<input type="button" value="检测窗口是否关闭" onclick="jiance()" />
		<div id="b"></div>
		<script>
			var a=null;
			
			function dakai(){
				a=window.open("","我的新窗口","width=400,height=200，left=200，top=100");
			    a.document.write(a.name+'<br>');
			    a.document.write(a.parent);
			}
			function guanbi(){
				if(a){
					a.close();
				}else{
					alert("还没有打开窗口")
				}
			}
			function jiance(){
				if(!a){
					s="窗口没有被打开";
				}else{             
					if(a.closed){
						s="窗口被关闭";
					}else{
						s="窗口未关闭";
					}
				}
				var b=document.getElementById("b");
				b.innerHTML=s;
			}
		</script>
	</body>
</html>
